#/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2022/1/11 9:20
# @Author  : wf
# @Email   : wf@163.com
# @File    : xshome_page.py
# @Software: PyCharm
"""添加线索页面"""
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.action_chains import ActionChains
xiansuo_locator=(By.LINK_TEXT,"线索")
xjxiansuo_locator=(By.CSS_SELECTOR,"body > div.container > div.row > div:nth-child(1) > div > a")
fuzeren_locator = (By.XPATH,'//*[@id="owner_name"]')
gxfuzeren_locator = (By.XPATH,'//*[@id="d_content"]/tr[1]/td[1]')
okfuzeren_locator = (By.XPATH,'/html/body/div[7]/div[3]/div/button[1]/span')
laiyuan_locator = (By.ID,'source')
zhiwei_locator = (By.ID,'position')
gongsi_locator = (By.ID,'name')
person_locator = (By.ID,'contacts_name')
mobile_locator = (By.ID,'mobile')
zuncheng_locator = (By.ID,'saltname')
email_locator = (By.ID,'email')
adress_locator = (By.CSS_SELECTOR,'#form1 > table > tbody > tr:nth-child(6) > td:nth-child(2) > select:nth-child(2)')
city_locator = (By.CSS_SELECTOR,'#form1 > table > tbody > tr:nth-child(6) > td:nth-child(2) > select:nth-child(3)')
next_time_locator = (By.NAME,'nextstep_time')
next_step_locator = (By.ID,'nextstep')
description_locator = (By.ID,'description')
baocun_locator = (By.CSS_SELECTOR,'#form1 > table > tfoot > tr > td > input:nth-child(1)')
tianjia_locator = (By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
lxrxm_locator=(By.CSS_SELECTOR,"#contacts_name")
class Tianjiaxiansuo_Page:
    def __init__(self,driver):
        self.driver=driver
    def click_xiansuo(self):
        self.driver.find_element(*xiansuo_locator).click()
    def click_xjxiansuo(self):
        self.driver.find_element(*xjxiansuo_locator).click()
    #输入负责人
    def input_fuzeren(self):
        self.driver.find_element(*fuzeren_locator).click()
        self.driver.find_element(*gxfuzeren_locator).click()
        self.driver.find_element(*okfuzeren_locator).click()
    def lxr(self,lxr):
        self.driver.find_element(*lxrxm_locator).send_keys(lxr)
    def input_laiyuan(self):
        self.driver.find_element(*laiyuan_locator).click()
    def input_zhiwei(self,zhiwei):
        self.driver.find_element(*zhiwei_locator).send_keys(zhiwei)
    def input_gongsi(self,gongsi):
        self.driver.find_element(*gongsi_locator).send_keys(gongsi)
    def input_person(self,person):
        self.driver.find_element(*person_locator).send_keys(person)
    def input_mobile(self,mobile):
        self.driver.find_element(*mobile_locator).send_keys(mobile)
    def input_zuncheng(self):
        zcxlk_element=self.driver.find_element(*zuncheng_locator)
        zcxlk_select=Select(zcxlk_element)
        zcxlk_select.select_by_index(1)
    def input_email(self,email):
        self.driver.find_element(*email_locator).send_keys(email)
    def input_adress(self):
        dzxlk_element = self.driver.find_element(*adress_locator)
        dzxlk_select = Select(dzxlk_element)
        dzxlk_select.select_by_index(1)
    def input_city(self):
        ctxlk_element = self.driver.find_element(*adress_locator)
        ctxlk_select = Select(ctxlk_element)
        ctxlk_select.select_by_index(1)
    def input_next_time(self,next_time):
        self.driver.find_element(*next_time_locator).send_keys(next_time)
    def input_next_step(self,next_step):
        self.driver.find_element(*next_step_locator).send_keys(next_step)
    def input_description(self,description):
        self.driver.find_element(*description_locator).send_keys(description)
    def input_baocun(self):
        self.driver.find_element(*baocun_locator).click()
    def xs_duanyan(self):
        dy_locator=(By.XPATH,'//*[@id="form1"]/table/tbody/tr[1]/td[4]/span')
        return self.driver.find_element(*dy_locator).text


